package com.chixing.controller;


import com.chixing.entity.Mycoupon;
import com.chixing.service.IMycouponService;
import com.chixing.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author smith
 * @since 2025-09-22
 */
@CrossOrigin
@RestController
@RequestMapping("/mycoupon")
public class MycouponController {

    @Autowired
    private IMycouponService mycouponService;

    @PostMapping
    public Result saveMyCoupon(@RequestBody Mycoupon mycoupon){
        Integer userId = 1 ;
        mycoupon.setUserId(userId);
        return mycouponService.save(mycoupon);
    }

    @GetMapping("/status/{status}")
    public Result getMyAllCoupons(@PathVariable("status") Integer status){
        Integer userId = 1 ;
        return mycouponService.getMyAllCoupons(userId,status);
    }

    @PutMapping("myCouponId/{myCouponId}/myCouponStatus/{myCouponStatus}")
    public Result updateStatus(@PathVariable("myCouponId") Integer myCouponId,
                               @PathVariable("myCouponStatus") Integer myCouponStatus ){
        return mycouponService.updateStatus(myCouponId,myCouponStatus);
    }
}
